<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="com.cpfmat.common.Contains,com.cpfmat.entity.ContentUser"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<style>
pre.pre-wrap{
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
}
</style>
<script type="text/javascript">
	function downloadAttachment(fileUrl,fileName){
		var form = document.createElement("form");
		form.action = "${basePath}/downloadAttachments";
		form.method = "post";
		form.target = "_blank";
		form.style.display = "none";
		var input = document.createElement("input");
		var input1 = document.createElement("input");
		input.name = "url";
		input.type = "hidden";
		input.value = fileUrl;
		input1.name = "fileName";
		input1.type = "hidden";
		input1.value = fileName;
		
		form.appendChild(input);
		form.appendChild(input1);
		
		document.body.appendChild(form);
		
		form.submit();
		document.body.removeChild(form);
	}
</script>

<form id="detailForm" class="am-form am-form-horizontal" data-am-validator>
<div class="am-form-group">
	<label for="title" class="am-u-sm-3 am-form-label am-text-right">技术成果名称</label>
	<div class="am-u-sm-7 am-u-end am-form-group am-margin-0">
		<pre class="pre-wrap">${contentUser.title}</pre>
	</div>
</div>
<div class="am-form-group">
	<label for="title" class="am-u-sm-3 am-form-label am-text-right">报送事项</label>
	<div class="am-u-sm-7 am-u-end am-form-group am-margin-0">
		<pre class="pre-wrap">${contentUser.submission}</pre>
	</div>
</div>
<div class="am-form-group">
	<label for="title" class="am-u-sm-3 am-form-label am-text-right">报送单位</label>
	<div class="am-u-sm-7 am-u-end am-form-group am-margin-0">
		<pre class="pre-wrap">${contentUser.unit}</pre>
	</div>
</div>
<div class="am-form-group">
	<label for="title" class="am-u-sm-3 am-form-label am-text-right">联系人</label>
	<div class="am-u-sm-7 am-u-end am-form-group am-margin-0">
		<pre class="pre-wrap">${contentUser.contactPerson}</pre>
	</div>
</div>	
<div class="am-form-group">
	<label for="title" class="am-u-sm-3 am-form-label am-text-right">联系电话</label>
	<div class="am-u-sm-7 am-u-end am-form-group am-margin-0">
		<pre class="pre-wrap">${contentUser.contactPhone}</pre>
	</div>
</div>
<%-- <div class="am-form-group">
	<label for="subTitle" class="am-u-sm-3 am-form-label am-text-right">技术成果简介</label>
	<div class="am-u-sm-7 am-u-end am-form-group am-margin-0">
		<pre class="pre-wrap">${contentUser.subTitle}</pre>
	</div>
</div> --%>

<div class="am-form-group">
	<label for="insertUser" class="am-u-sm-3 am-form-label am-text-right">报送人</label>
	<div class="am-u-sm-7 am-u-end am-form-group am-margin-0">
		<pre class="pre-wrap">${contentUser.userId}</pre>
	</div>
</div>

<div class="am-form-group">
	<label for="insertUser" class="am-u-sm-3 am-form-label am-text-right">技术成熟度</label>
	<div class="am-u-sm-7 am-u-end am-form-group am-margin-0">
		<pre class="pre-wrap">${contentUser.tecExp}</pre>
	</div>
</div>

<div class="am-form-group">
	<label for="description" class="am-u-sm-3 am-form-label am-text-right">专项领域</label>
	<div class="am-u-sm-7 am-u-end am-form-group am-margin-0">
		<pre class="pre-wrap"><%
			ContentUser content = (ContentUser) request.getAttribute("contentUser");
			if(content != null && content.getSpecialField() != null){
				out.print(Contains.specialFieldMap.get(content.getSpecialField()));
			}
			else{
				out.print("其他");
			}
		%></pre>
	</div>
</div>

<div class="am-form-group">
	<label for="description" class="am-u-sm-3 am-form-label am-text-right">技术成果简介</label>
	<div class="am-u-sm-7 am-u-end am-form-group am-margin-0">
		<pre class="pre-wrap">${contentUser.content}</pre>
	</div>
</div>

<c:if test="${(contentUser.shzt eq 'N' or contentUser.shzt eq 'n') and !empty contentUser.finalRejection}">
<div class="am-form-group">
	<label for="description" class="am-u-sm-3 am-form-label am-text-right">审核不通过原因</label>
	<div class="am-u-sm-7 am-u-end am-form-group am-margin-0">
		<pre class="pre-wrap">${contentUser.finalRejection}</pre>
	</div>
</div>
</c:if>

<c:if test="${!empty attachments}">
	<div class="am-form-group">
		<div>
			<label class="am-u-sm-3 am-form-label am-text-right">附件</label>
		</div>
		<div id="downLoadDiv">
			<div class="am-form-group">
			<c:forEach items="${attachments }" var="attachment" varStatus="status">
				<div class="am-u-sm-9 am-fr am-margin-bottom-sm <c:if test="${status.first }">am-margin-top-sm</c:if>">
					<button type="button"
						onclick="downloadAttachment('${attachment.filePath }','${attachment.fileName }')"
						title="${attachment.fileName }"
						class="am-btn am-btn-default am-btn-sm">
						<c:choose>
							<c:when test="${fn:length(attachment.fileName) > 10}">
								<c:set var="fileName" value="${fn:substring(attachment.fileName, 0, 10)}..." />
							</c:when>
							<c:otherwise>
								<c:set var="fileName" value="${attachment.fileName}" />
							</c:otherwise>
						</c:choose>
						<i class="am-icon-download" style="max-width: 200px;">${fileName}</i>
					</button>
				</div>
			</c:forEach>
			</div>
		</div>
	</div>
</c:if>

<div class="am-form-group">
	<div class="am-u-sm-3 am-u-sm-centered">
		<button type="button" class="am-btn am-btn-primary am-btn-xs"
			onclick="usercont.close();">返回</button>
	</div>
</div>
</form>
</html>